{include file="index/header" /}
<body>
<div class="panel admin-panel">
  <div class="panel-head"><strong class="icon-reorder"> 内容列表</strong></div>
  <div class="padding border-bottom">  
  <button type="button" class="button border-yellow" onclick="window.location.href='{:url('role/add')}'"><span class="icon-plus-square-o"></span> 添加内容</button>
  </div>
  <form method="post" action="" id="listform">
  <table class="table table-hover text-center">
    <tr>
      <th width="10%">ID</th>
      <th width="10%">角色名称</th>
      <th width="15%">操作</th>
    </tr>
    {foreach name='data' item='v'}
    <tr>
      <td><input type="checkbox" name="role_id[]" value="{$v.role_id}" />{$v.role_id}</td> 
      <td>{$v.role_name}</td>
      <td><div class="button-group">{if $v.role_id neq 1}
      <a class="button border-main" href="{:url('role/privilege',['role_id' => $v['role_id']])}"><span class="icon-edit"></span> 权限设置</a>
      <a class="button border-main" href="{:url('role/edit',['role_id' => $v['role_id']])}"><span class="icon-edit"></span> 修改</a>
      <a class="button border-red" href="{:url('role/delete',['role_id' => $v['role_id']])}" onclick="if(confirm('确定删除?')==false)return false;"><span class="icon-trash-o"></span> 删除</a>{/if}
      </div></td>
    </tr>
    {/foreach}
    <!-- <tr>
        <td><input type="checkbox" id="checkall"/>
          全选 </td>
        <td colspan="5" style="text-align:left;padding-left:20px;"><a href="javascript:void(0)" class="button border-red icon-trash-o" style="padding:5px 15px;" onclick="DelSelect()"> 删除</a></td>
      </tr> -->
  </table>
  <input type="hidden" name="status" value="">
  </form>
</div>
<div class="panel admin-panel margin-top" id="add">
  <div class="panel-head"><strong><span class="icon-pencil-square-o"></span> 增加内容</strong></div>
  <div class="body-content">
    <form method="post" class="form-x" action="{:url('role/add')}">    
      <div class="form-group">
        <div class="label">
          <label>角色名称：</label>
        </div>
        <div class="field">
          <input type="text" class="input w50" value="" name="role_name" placeholder="请输入角色名" data-validate="required:请输入角色名" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <button class="button bg-main icon-check-square-o" type="submit"> 提交</button>
        </div>
      </div>
    </form>
  </div>
</div>
</body></html>
<script>
  //全选
$("#checkall").click(function(){ 
  $("input[name='role_id[]']").each(function(){
    if (this.checked) {
      this.checked = false;
    }
    else {
      this.checked = true;
    }
  });
});

//批量删除
function DelSelect(){
  var Checkbox=false;
   $("input[name='role_id[]']").each(function(){
    if (this.checked==true) {   
    Checkbox=true;  
    }
  });
  if (Checkbox){
    var t=confirm("您确认要删除选中的内容吗？");
    if (t==false) return false;   
    $('input[name=status]').val('del');
    $("#listform").submit();    
  }
  else{
    alert("请选择您要删除的内容!");
    return false;
  }
}

</script>